///<reference path="../core/mengdao/api/mvc/BaseBundle.ts"/>
///<reference path="module/command/StageResizeCommand.ts"/>
/**
 * Created by PengWei on 2018/7/24.
 */
namespace game {

    import BaseBundle = mengdao.BaseBundle;
    import StageResizeCommand = game.StageResizeCommand;

    /**
     * Mvc配置
     * 需要在context初始化之前完成绑定
     */
    export class GameMvc extends BaseBundle {

        public initialize(): void {
            this.configModel();
            this.configService();
            this.configView();
            this.configFactory();
            this.configManager();
            this.configCommand();
        }

        /**
         * 配置 Model
         */
        private configModel(): void {
            this.mapConst(PlayerModel);
            this.mapConst(BarModel);
        }

        /**
         * 配置 Service
         */
        private configService(): void {
            this.mapConst(PlayerService);
            this.mapConst(NetService);
        }

        /**
         * 配置 View 和 Mediator
         */
        private configView(): void {
        }

        private configFactory(): void {
            this.mapConst(DbFactory).initialize();
        }

        private configManager():void{
            this.mapConst(WindowManager).initialize()
        }

        /**
         * 配置事件和响应函数
         */
        private configCommand(): void {
            //------------------ 初始化命令 ------------------
            this.mapCommand(GameEvent.EXECUTE_INIT, InitProcessCommand, true); //进入游戏流程初始化
            this.mapCommand(GameEvent.EXECUTE_LOGIN, LoginProcessCommand, true); //登录流程
            this.mapCommand(GameEvent.INIT_LAYER, InitLayerCommand, true);//初始化层级

            //------------------ 全局命令 ------------------
            this.mapCommand(UIEvent.OPEN, OpenUICommand, false);
            this.mapCommand(UIEvent.CLOSE, CloseUICommand, false);
            this.mapCommand(GameEvent.ADD_MODAL,UpdateModalCommand,false);
            this.mapCommand(GameEvent.REMOVE_MODAL,UpdateModalCommand,false);

            //------------------ 即时启动命令 ------------------
            this.executeCommand(StageResizeCommand);
        }
    }
}